<?php
$control->renderView('weChatShare');
//获取当前user信息
$userCooker = new BAUserCooker();
$userInfo = $userCooker->getUserInfo();
//var_dump($userInfo);
$familyNameAttr = '';
$surNameAttr = '';
if ($userInfo->getItem('familyName') != NULL)
    $familyNameAttr = $userInfo->getItem('familyName')->getValue();
if ($userInfo->getItem('surName') != NULL)
    $surNameAttr = $userInfo->getItem('surName')->getValue();
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/wei_webapp_new.css' ?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/wei_dialog.css' ?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl . '/css/BWeMember/common.css' ?>">

<!-- ajax加载页面时弹出加载旋转gif图 -->
<style>
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
<style type="text/css">
    /*	.main{width: 350px;height: 100px;background-color: white;padding-top: 8px;}
            .tu{width:96px;height: 74px;float: left;margin-left: 8px;}
            .wen{width: 200px;float: left;margin-left: 10px;}
            .wen p {line-height: 28px;}*/
    #imgGo {overflow: hidden; position: relative;  padding: 0;margin: 0 auto;}
    #imgGo ul {overflow: hidden; position: absolute; top: 0; left: 0; margin: 0; padding: 0;}
    #imgGo ul li {overflow: hidden; float: left; margin: 0; padding: 0;}
    #imgIndex {overflow: hidden; position: absolute; bottom: 0; margin: 0; padding-right:50%; width: 100%; height: 12%; text-align: center;}
    #imgIndex span {display: inline-block; width: 10px; height: 10px; margin-right: 3%; border-radius: 100%; background-color: #BDBDBD;cursor: pointer; opacity: 0.4;}

    .shadow{height: 60px;width: 290px;background-color: black;border-radius: 5px;opacity:0.45;}
    .img{position:absolute;top: 180px;left: 50%;margin-left:-146px;}
    img.s{border:0;height: 100px;width:100%;}
    img.l{border:0;height: 60px;width:60px;display:inline-block;margin-bottom:10px;}
        .enableApply{
        padding-top: 5px;
        line-height: 32px;
        text-align: left;
        color: #373B3E;
        font-size: 14px;
        padding-left: 21px;
        font-weight: bold;
    }
</style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="<?php echo Yii::app()->request->baseUrl . '/images/ajax-loader.gif' ?>" class="ajax-loader">
</div>


<div id="page_card" class="div-body">

    <div id="mappContainer">
        <div class="inner root" style="height: 519px;">
            <div class="card" style="-webkit-background-size:267px 159px;background-size:267px 159px;box-shadow: none;height: 40px;" data-card-type="0">
            </div>
            <?php
            if (!$voucherView && !$applyCount) {//没有消费券，也没有可以领取的消费券
                ?>
                <p class="enableApply" style="font-weight: normal;margin-top: 15px;padding: 5px;font-weight: normal;">尊敬的客户，您目前没有代金券，感谢您的关注！</p>
                <?php
            }
            ?>
            <?php if ($voucherView) { ?>
                <h2 class="enableApply">已领取的代金券</h2>
                <ul class="round"> 
                    <?php
                    $voucherCooker = new BAVoucherCooker();
                    $userCooker = new BAUserCooker();
                    $permitCooker = new BAPermitCooker();

                    foreach ($voucherView as $id => $list) {
                        $userInfoId = $list->getItem('userInfoId')->getValue();
                        $voucherId = $list->getItem('voucherId')->getValue();
                        $voucherTypeId = $list->getItem('voucherTypeId')->getValue();
                        $permitId = $list->getItem('permitId')->getValue();
                        $voucherType = $voucherCooker->getVoucherType($voucherTypeId);
                        $userInfo = $userCooker->getUserInfo($userInfoId);
                        $oPermit = $permitCooker->getPermit($permitId);
                        //$voucher = $voucherCooker->getVoucher($voucherId);
                        $voucherTypeAlias = $voucherType->getValue();
                        $after10year = strtotime("+10 years");
                        $expire = $oPermit->getItem('expireTime')->getValue();
                        if ($expire > $after10year) {
                            $expireTime = '10年后';
                        } else {
                            $expireTime = date('Y/m/d:H', $expire);
                        }

                        $name = '---';
                        if ($userInfo != NULL) {
                            if ($userInfo->getItem('familyName') != NULL) {
                                $name = $userInfo->getItem('familyName')->getValue();
                            }
                            if ($userInfo->getItem('surName') != NULL) {
                                $surName = $userInfo->getItem('surName')->getValue();
                                if ($name == '---')
                                    $name = $surName;
                                else {
                                    $name.=$surName;
                                }
                            }
                        }
                        ?>

                        <li style="margin-bottom: 10px;margin-top: 10px;">
                            <div class="card" style="-webkit-background-size:267px 159px;height: 50px;width: 100%;" data-card-type="0">
                                <strong class="pdo verify" style="top: 10px;">
                                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;float: left;margin-left: 10px;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">代金券类型</em><?php echo $voucherTypeAlias; ?></span>
                                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">券号</em><?php echo $voucherTypeId; ?></span>
                                </strong>
                            </div>
                        </li>
                    <?php } ?>
                </ul>
                <?php
            }
            ?>
            <?php
            if ($applyCount) {//有可以申请的会员卡
                ?>
                <p class="enableApply" style="font-weight: normal;margin-top: 15px;padding: 5px;font-weight: normal;">尊敬的客户，您有<a style="font-weight: bold;"><?php echo $applyCount . '张'; ?></a>可以领取的代金券，点击以下按钮领取代金券！</p>
                <ul  style="text-align: center;"> <!--class="round"-->
                    <?php
                    echo $control->getAjaxLink('领取代金券', array(
                        'cooker' => 'BAVoucher@showUserVoucherApplyList',
                        'htmlOptions' => array('class' => 'btn btn-success')
                    ));
                    ?>
                </ul>
                <?php
            }
            ?>
        </div>


        <?php
        $returnUrl = $control->getAjaxScript('返回会员卡页', array(
            'cooker' => 'BAMemberCard@showUserCardHome',
        ));
        ?>
        <div class="footFix" id="footReturn"><a  href="javascript:void(0)" onclick="<?php echo $returnUrl; ?>"><span>返回会员卡页</span></a></div>
    </div>
</div>
